package org.example.day01;

/**
 * 第一章节1.7.8:通过return停止线程
 */
public class MyThread10 extends Thread{
    @Override
    public void run() {
        while(true){
            if(this.isInterrupted()){
                System.out.println("放假了");
                return;
            }
            System.out.println("时间:" + System.currentTimeMillis());
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread10 m10 = new MyThread10();
        m10.start();
        Thread.sleep(2000);
        m10.interrupt();
    }
}
